package com.wm.cmsService.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.wm.cmsService.entity.CrmBanner;
import com.wm.cmsService.mapper.CrmBannerMapper;
import com.wm.cmsService.service.CrmBannerService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 首页banner表 服务实现类
 * </p>
 *
 * @author sshdg
 * @since 2020-10-07
 */
@Service
public class CrmBannerServiceImpl extends ServiceImpl<CrmBannerMapper, CrmBanner> implements CrmBannerService {


    /**
     * 查询所有banner
     *
     * @return
     */
    @Override
    @Cacheable(key = "'selectIndexList'",value = "banner")
    public List<CrmBanner> selectAllBanners() {
        LambdaQueryWrapper<CrmBanner> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByAsc(CrmBanner::getGmtModified);
        wrapper.last("limit 2");
        List<CrmBanner> list = this.list();
        return list;
    }
}
